<!--
* description: 备件标签打印
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamicButtons="tableButtons"
      :dynamicComponents="tableComponents"
      :dynamicApiConfig="apiConfig"
      :dynamicTableCols="tableCols"
      :dynamicFormFields="formField"
      :dynamicIsShowSelect="false"
      :dynamicIsColumnDrop="true"
    >
      <template slot="controlBtn" slot-scope="scope">
        <el-link
          type="primary"
          class="el-icon-printer"
          :underline="false"
          @click="edit(scope.row.index)"
          style="font-size:12px;"
        >标签打印</el-link>
      </template>
    </one-table-template>
    <edit
      :dynamicEditRowData="editRowData"
      :popupsVisible="editPopupsVisible"
      :key="editPopupsKey"
      :popupsState="editPopupsState"
      @close="close"
    ></edit>
  </div>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { wmsApis } from "@/api/wms/baseData/api";
import OneTableTemplate from "@/components/wms/templates/oneTable";
// import httpRequestExport from "@utils/wms/export"
import request from "@/utils/request";
export default {
  name: "partInfo",
  // 组件混入对象
  mixins: [oneTableWithViewTemplateMixins],
  components: {
    OneTableTemplate,
    Edit: () => import("./edit")
  },
  watch: {
    $route(val) {
      if (
        this.formField.pageId !== "" &&
        this.$route.query.pageId !== undefined &&
        this.$route.query.pageId !== this.formField.pageId
      ) {
        this.formField.pageId = this.$route.query.pageId;
        this.formField.pageName = this.$route.query.pageName;
        this.queryTable();
      }
    }
  },
  created() {
    if (this.$route.query != null) {
      // 判断传入query参数，初始化数据
      if (this.$route.query.pageId != null && this.$route.query.pageId !== "") {
        this.formField.pageId = this.$route.query.pageId;
        this.formField.pageName = this.$route.query.pageName;
      }
    }
  },
  mounted() {
    this.queryTable();
  },
  data() {
    return {
      // 网格查询API配置对象
      apiConfig: wmsApis.queryPartList,
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(),
          name: "search",
          position: "right",
          text: "查询" //"查询"
        },
        {
          compKey: "btnKey3",
          type: "",
          size: "small",
          name: "reset",
          position: "right",
          clickEvent: () => this.reset(),
          text: "重置" //"重置"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        {
          compKey: "compKey1",
          labelName: "备件编号",
          codeField: "PART_NO",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey2",
          labelName: "备件名称",
          codeField: "PART_NAME",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true
        }
      ],
      // 动态生成网格列
      tableCols: [
        {
          prop: "controlBtn",
          label: "操作",
          codeField: "controlBtn",
          width: 80,
          align: "center",
          isSlot: true
        },
        {
          prop: "PART_NO",
          label: "备件编号",
          align: "center"
        },
        {
          prop: "PART_NAME",
          label: "备件名称",
          align: "center"
        },
        {
          prop: "UNIT",
          label: "单位",
          align: "center"
        },
        {
          prop: "PART_CUBAGE",
          label: "备件体积（mm³）",
          align: "center"
        },

        {
          prop: "LENGTH",
          label: "长（mm）",
          align: "center"
        },

        {
          prop: "WIDTH",
          label: "宽（mm）",
          align: "center"
        },

        {
          prop: "HEIGHT",
          label: "高（mm）",
          align: "center"
        },
        {
          prop: "SNP_IN",
          label: "采购SNP",
          align: "center"
        },
        {
          prop: "SNP_OUT",
          label: "销售SNP",
          align: "center"
        },
        {
          prop: "SNP_MOVE",
          label: "调拨SNP",
          align: "center"
        },
        {
          prop: "IS_ENABLE_STR",
          label: "状态",
          align: "center"
        }
      ],
      //表单查询数据
      formField: {
        PART_NO: "",
        PART_NAME: ""
      }
    };
  },
  methods: {}
};
</script>
